package sctu.edu.java.year2016.team04.luoxinghua.day20160605.chapter12_3;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Scanner;

/**当输入密码和用户时存入文件
 * Created by 落叶的思恋 on 2016/6/19.
 */
public class NamePasswordWork12_3 {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        File file = new File("D:\\Work", "work12-3.txt");
        if (file.exists()) {
            System.out.println("file already exists");
        } else
            file.createNewFile();
        System.out.println("please enter name");
        String str = scan.nextLine();
        byte[] bytes=new byte[2048];
        bytes=str.getBytes();
        FileOutputStream fileOutputStream=new FileOutputStream(file);
        fileOutputStream.write(bytes);
        System.out.println("please enter password");
        String ss=scan.nextLine();
        byte[] bytes1=new byte[10000];
        bytes1=ss.getBytes();
        fileOutputStream.write(bytes1);
    }

}
